package ssm;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import spring_hibernate.*;

import javax.sql.DataSource;

/**
 * Created by jack on 18/6/2.
 */
public class BookTest {
    private ApplicationContext context = null;
    private BookService bookService = null;
    {
        context = new ClassPathXmlApplicationContext("ssm/demo.xml");
        bookService =  context.getBean(BookService.class);
    }
    @Test
    public void test()
    {
        DataSource dataSource = context.getBean(DataSource.class);
        System.out.println(dataSource);
    }

    @Test
    public void test2()
    {
        String bookName=bookService.findBookById(1);
        System.out.println(bookName);
    }

    @Test
    public void test3()
    {
        bookService.saveBook(new Book(2, "android source", "1002", 45, 10));
    }

    public static void main(String[] args) {

    }
}
